package com.aviation.sell_ticket.service.impl;

import com.aviation.sell_ticket.mapper.LoginRecordMapper;
import com.aviation.sell_ticket.pojo.Aviation_login_record;
import com.aviation.sell_ticket.service.LoginRecordService;
import com.aviation.sell_ticket.tool.ResultEnum;
import com.aviation.sell_ticket.tool.ResultUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class LoginRecordServiceImpl implements LoginRecordService {

    @Resource
    LoginRecordMapper loginRecordMapper;


    @Override
    public Boolean addLoginRecord(Aviation_login_record loginRecord) {
        return loginRecordMapper.addLoginRecord(loginRecord)>0;
    }

    @Override
    public Map<String, Object> queryLoginInformation(String userId, String pageNumber) {
        try {
            int page=Integer.parseInt(pageNumber);
            page=page*5;
            return ResultUtil.success(ResultEnum.SUCCESS, loginRecordMapper.queryLoginInformation(userId,page));
        }catch (Exception e){
            return ResultUtil.beDefeated(ResultEnum.UNKNOWN_ERROR);
        }
    }
}
